<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
	<title>用户管理</title>
	<script type="text/javascript">
		
		$(function(){
			
			$(".delete").click(function(){
				alert(url.USER_LIST);
				//alert("delete");
				var loginName = $(this).parent().parent().find("td:eq(0)").text();
				var flag = confirm("确定要删除"+loginName+"吗?");
				if(!flag)
					return false;
				var deleteUrl = $(this).attr("href");
				$.ajax({
		    		  type: "GET",
		    		  url: deleteUrl,
		    		  async: false,
		    		  success: function(result) {
		    			  if(result.code == 0) {
		    				  layer.msg("删除成功", {icon: 1, time: 1000},function() {
		    						window.location.href = window.url.USER_LIST;
		    							return;
		    					  });
		    			  }else if(result.code == 1) {
		    				  $("#message").html("系统出错,更新失败,请稍后再试!").show();
		    			  }
		    		  }
		    	  });
				
				return false;
			});
		});
	
	</script>
</head>

<body>
	<div id="message" class="alert alert-danger" style="display: none;">
	</div>
	
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead><tr><th>登录名</th><th>用户名</th><th>注册时间<th>管理</th></tr></thead>
		<tbody>
		<c:forEach items="${users}" var="user">
			<tr>
				<td><a href="${ctx}/admin/user/update/${user.id}">${user.loginName}</a></td>
				<td>${user.name}</td>
				<td>
					<fmt:formatDate value="${user.registerDate}" pattern="yyyy年MM月dd日  HH时mm分ss秒" />
				</td>
				<td><a class="delete" href="${ctx}/admin/user/delete/${user.id}">删除</a></td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
</body>
</html>
